package demo;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: Lenovo
 * Date: 2025-03-20
 * Time: 20:48
 */
public class Student {
    private String name;
    private int age;
    private static String classRoom;
    //实例代码块
    {
        this.name = "liming";
        this.age = 18;
        System.out.println("实例代码块!");
    }

    // 静态代码块
    static {
        classRoom = "one";// 初始化静态变量
        System.out.println("静态代码块!");
    }

    public Student(){
        System.out.println("构造方法!");
    }

    public static void main(String[] args) {
        System.out.println("main方法！");
        System.out.println("静态变量的值: " + classRoom);
        Student s1 = new Student();
        System.out.println("/");
        Student s2 = new Student();
    }
}
/*
运行

        静态代码块!
        main方法！
        静态变量的值: one
        实例代码块!
        构造方法!
        /
        实例代码块!
        构造方法!
*/